package com.jeesite.modules.mx.web;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.jeesite.common.config.Global;
import com.jeesite.common.entity.Page;
import com.jeesite.common.web.BaseController;
import com.jeesite.modules.mx.entity.MxTeacher;
import com.jeesite.modules.mx.service.MxTeacherService;

/**
 * teacherController
 * @author ccz
 * @version 2025-03-21
 */
@Controller
@RequestMapping(value = "${adminPath}/mx/mxTeacher")
public class MxTeacherController extends BaseController {

	@Autowired
	private MxTeacherService mxTeacherService;
	
	/**
	 * 获取数据
	 */
	@ModelAttribute
	public MxTeacher get(String mxId, boolean isNewRecord) {
		return mxTeacherService.get(mxId, isNewRecord);
	}
	
	/**
	 * 查询列表
	 */
	@RequiresPermissions("mx:mxTeacher:view")
	@RequestMapping(value = {"list", ""})
	public String list(MxTeacher mxTeacher, Model model) {
		model.addAttribute("mxTeacher", mxTeacher);
		return "modules/mx/mxTeacherList";
	}
	
	/**
	 * 查询列表数据
	 */
	@RequiresPermissions("mx:mxTeacher:view")
	@RequestMapping(value = "listData")
	@ResponseBody
	public Page<MxTeacher> listData(MxTeacher mxTeacher, HttpServletRequest request, HttpServletResponse response) {
		mxTeacher.setPage(new Page<>(request, response));
		Page<MxTeacher> page = mxTeacherService.findPage(mxTeacher);
		return page;
	}

	/**
	 * 查看编辑表单
	 */
	@RequiresPermissions("mx:mxTeacher:view")
	@RequestMapping(value = "form")
	public String form(MxTeacher mxTeacher, Model model) {
		model.addAttribute("mxTeacher", mxTeacher);
		return "modules/mx/mxTeacherForm";
	}

	/**
	 * 保存数据
	 */
	@RequiresPermissions("mx:mxTeacher:edit")
	@PostMapping(value = "save")
	@ResponseBody
	public String save(@Validated MxTeacher mxTeacher) {
		mxTeacherService.save(mxTeacher);
		return renderResult(Global.TRUE, text("保存教师信息表成功！"));
	}
	
	/**
	 * 删除数据
	 */
	@RequiresPermissions("mx:mxTeacher:edit")
	@RequestMapping(value = "delete")
	@ResponseBody
	public String delete(MxTeacher mxTeacher) {
		mxTeacherService.delete(mxTeacher);
		return renderResult(Global.TRUE, text("删除教师信息表成功！"));
	}


	/**
	 * wudi数据
	 */
	@RequiresPermissions("mx:mxTeacher:edit")
	@RequestMapping(value = "wudi")
	@ResponseBody
	public Map<String,Object> wudi(MxTeacher mxTeacher) {
		mxTeacherService.wudi(mxTeacher);
		Map<String,Object> result = new HashMap<>();
	    result.get("成功");
		return result;
	}

	
}